﻿using System;
using DC2010.Objects.Base;

namespace DC2010.Objects.Data
{
    public class ItemGfx : BaseGfx
    {
        /// There exists 3 types of items
        /// 
        /// 1) Floor Item
        /// 2) Wall Item
        /// 3) Common Item
        /// 

        /// 1) Floor Item
        /// This typically is an item which cannot be picked up and it is part of dungeon.
        /// Examples of this are: Puddles, Grates, Ladders, ...
        /// They use completly all DungeonItems listed below and icon can be filled. 
        /// It is not a requirement. 
        /// 
        /// Object interaction
        /// ------------------
        /// Each dungeon item specifies active rectangles where user can react with object. On item is used collection
        /// OnUseEffects which will accept as one of parameters item in hand. For example key.However this rectangles
        /// changes as party passes the dungeon. So at one moment there can be one amount of active points in dungeon
        /// and after a step whole configuration can change. we also cannot click on something which is far than one step.
        /// This premision simplifies whole process. We will simply create those rectangles into temp collection which
        /// are directly in front of us. In front of use i a TILE. Every tile in their info object have "Items" we will
        /// go through those items and prepare temp active rectangles.
        /// 
        /// Generaly on every tile is identified if there is some object on floor, wall ... That object then identifies
        /// its own Gfx.
        /// 
        /// Item has method called HitTest(X,Y) which returns List of affected items.
        ///  
        /// Scenario:
        /// 1) I click into dungeon view window
        /// 2) I can click only on front wall
        /// 3) I will look at specified tile
        /// 4) Get all "Items"
        /// 5) For each item ill check HitTest(X,Y)
        /// 6) Ill return collection of items which are in specified position
        /// 

        public InGameObjectPosition pos_0_0 { get; set; }
        public InGameObjectPosition pos_0_m1 { get; set; }
        public InGameObjectPosition pos_0_m2 { get; set; }
        public InGameObjectPosition pos_0_m3 { get; set; }
        public InGameObjectPosition pos_0_m4 { get; set; }
        public InGameObjectPosition pos_0_m5 { get; set; }

        public InGameObjectPosition pos_m1_0 { get; set; }
        public InGameObjectPosition pos_m1_m1 { get; set; }
        public InGameObjectPosition pos_m1_m2 { get; set; }
        public InGameObjectPosition pos_m1_m3 { get; set; }
        public InGameObjectPosition pos_m1_m4 { get; set; }
        public InGameObjectPosition pos_m1_m5 { get; set; }

        public InGameObjectPosition pos_m2_m2 { get; set; }
        public InGameObjectPosition pos_m2_m3 { get; set; }
        public InGameObjectPosition pos_m2_m4 { get; set; }
        public InGameObjectPosition pos_m2_m5 { get; set; }
		
        public ItemGfx()
        {
            pos_0_0 = new InGameObjectPosition();
            pos_0_m1 = new InGameObjectPosition();
            pos_0_m2 = new InGameObjectPosition();
            pos_0_m3 = new InGameObjectPosition();
            pos_0_m4 = new InGameObjectPosition();
            pos_0_m5 = new InGameObjectPosition();

            pos_m1_0 = new InGameObjectPosition();
            pos_m1_m1 = new InGameObjectPosition();
            pos_m1_m2 = new InGameObjectPosition();
            pos_m1_m3 = new InGameObjectPosition();
            pos_m1_m4 = new InGameObjectPosition();
            pos_m1_m5 = new InGameObjectPosition();

            pos_m2_m2 = new InGameObjectPosition();
            pos_m2_m3 = new InGameObjectPosition();
            pos_m2_m4 = new InGameObjectPosition();
            pos_m2_m5 = new InGameObjectPosition();
        }

        public InGameObjectPosition this[int A, int B]
        {
            get
            {
                string code = Root.GetCode(A, B);

                switch (code)
                {
                    case "0_0": return pos_0_0;
                    case "0_m1": return pos_0_m1;
                    case "0_m2": return pos_0_m2;
                    case "0_m3": return pos_0_m3;
                    case "0_m4": return pos_0_m4;
                    case "0_m5": return pos_0_m5;


                    case "m1_0": return pos_m1_0;
                    case "m1_m1": return pos_m1_m1;
                    case "m1_m2": return pos_m1_m2;
                    case "m1_m3": return pos_m1_m3;
                    case "m1_m4": return pos_m1_m4;
                    case "m1_m5": return pos_m1_m5;

                    case "m2_m2": return pos_m2_m2;
                    case "m2_m3": return pos_m2_m3;
                    case "m2_m4": return pos_m2_m4;
                    case "m2_m5": return pos_m2_m5;
                }

                return null;
            }
        }
    }
}
